
Montage is a general astronomical image toolkit with facilities for reprojection, background matching, coaddition and visualization. It can be used as a set of command-line tools (Linux, OS X and Windows), C library calls (Linux and OS X) and as Python binary extension modules.
Montage source code can be downloaded from GitHub ( https://github.com/Caltech-IPAC/Montage ). The Python package can be installed from PyPI ("pip install MontagePy"). See http://montage.ipac.caltech.edu/ for more information.
A large percentage of the Montage modules focus on processing a set of images (often retrieved from a mission archive); projecting them to a common frame, adjusting their background levels as a set, and coadding them into a mosaic.
This page is focused on the details of one of these modules: mOverlaps. For a broader context, please see Building a Mosaic with Montage or the one shot version if you just want to see the commands.
Note: The MontagePy python package has no external dependencies. We include other utilities on this page to aid in visualizing MontagePy package results.
from MontagePy.main import mOverlaps, mViewer
help(mOverlaps)
In a test region near M17 we have 48 J-band images. Here we use mOverlaps to determine which of these overlap and by how much.
import os
try:
os.makedirs('work/M17')
except:
pass
rtn = mOverlaps("M17/pimages.tbl", "work/M17/diffs.tbl")
print(rtn)
Here is the output
import os
import numpy as np
import pandas as pd
from astropy.io import ascii
ipactable = ascii.read('work/M17/diffs.tbl').to_pandas()
ipactable
and here is a coverage map illustrating the overlaps:
from IPython.display import Image
rtn = mViewer("-color black -imginfo M17/pimages.tbl \
-ct 1 -gray M17/mosaic.fits -2s max gaussian-log \
-out work/M17/mosaic.png",
"", mode=2)
Image(filename='work/M17/mosaic.png')
If mDiff encounters an error, the return structure will just have two elements: a status of 1 ("error") and a message string that tries to diagnose the reason for the error.
For instance, if the user specifies a table that doesn't exist:
rtn = mOverlaps("M17/unknown.tbl", "work/M17/diffs.tbl")
print(rtn)
mOverlaps can also be run as a command-line tool in Linux, OS X, and Windows:
Usage: mOverlaps [-e] [-d level] [-s statusfile] images.tbl diffs.tbl
If you are writing in C/C++, mOverlaps can be accessed as a library function:
/*-***********************************************************************/ /* */ /* mOverlaps */ /* */ /* Given a list of images, determines which ones overlap. This program */ /* assumes that the images are relatively small (i.e. not all-sky) and */ /* determines if there is overlap by going around the outside of each */ /* to see if any of the edge pixels are inside the other. */ /* */ /* char *tblfile Image metadata file */ /* char *difftbl Output table of overlap areas */ /* */ /* int quickmode Use faster but fairly accurate overlap check */ /* rather than full geometry calculation */ /* */ /* int debug Debugging output level */ /* */ /*************************************************************************/ struct mOverlapsReturn *mOverlaps(char *tblfile, char *difftbl, int quickmode, int debug)
Return Structure
struct mOverlapsReturn
{
int status; // Return status (0: OK, 1:ERROR)
char msg [1024]; // Return message (for error return)
char json[4096]; // Return parameters as JSON string
int count; // Number of overlaps.
};